﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using VK.Casemeet.Magazines;
using VK.Comm.TransactSql;
using System.Data;

namespace VK.Casemeet.Web.Front
{
    public partial class MagazineList : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            TopArticle1.AreaUrl = (this.Master as Site).GetAreaUrl();
            TopArticle1.ProvinceID = (this.Master as Site).provinceID;
            TopArticle1.CityID = (this.Master as Site).cityID;

            if (!IsPostBack)
            {
                aspNetPager.RecordCount = MagazineBLL.GetMagazineCount(GetCondition());
            }
        }

        protected void LoadData()
        {
            rptMagazine.DataSource = MagazineBLL.GetMagazineList(aspNetPager.StartRecordIndex, aspNetPager.EndRecordIndex, GetCondition(), null, SortMode.Desc);
            rptMagazine.DataBind();
        }

        protected IList<Condition> GetCondition()
        {
            IList<Condition> conditionlst = new List<Condition>();
            conditionlst.Add(new Condition { TableName = "Magazine", FieldName = "IsEnable", ConditionType = ConditionType.BoolEqual, ConditionValue = true, DbType = DbType.Boolean });
            return conditionlst;
        }

        protected void aspNetPager_PageChanged(object sender, EventArgs e)
        {
            LoadData();
        }
    }
}